<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">  
  <title>鲜花列表</title>
 </head>
 <body>
 <?php
  require_once('system/dbConnect.php');
  require_once('system/MyFunc.php');
  connect();
  $sql = 'select * from flower';
  if($_POST['key'])  
  {
    $key = trim($_POST['key']);
    $sql = $sql." where wn_title like '%{$key}%' ";
  }
  $result = fetch_array($sql);
  ?>
  <table align="center" width="80%">
 <tr><td  align="left" >
 <form method=post action="">
    请输入用户名：
  <input type="text" name="key">
  <input type="submit" name='search' value="搜索">  
 </form> 
 </td></tr>
 </table>
 <table align="center" width="80%" border=1>  
 <center><h3>鲜花列表</h3></center> 
 <tr>
   <th>鲜花标题</th>   
   <th>鲜花产地</th>
   <th>添加鲜花的时间</th>
   <th>点击量</th>
   <th>操作</th> 
 </tr>
 <?php
  foreach($result as $row) 
  {
   echo '<tr>';
   echo '<td><a href="detail.php?id='.$row['wn_id'].' "> '.$row['wn_title'].'</a></td>';
   echo '<td>'.$row['wn_place'].'</td>';
   echo '<td>'.$row['wn_adddate'].'</td>';
   echo '<td>'.$row['wn_hint'].'</td>';
   echo '<td><a href="flowerupdate.php?id='.$row['wn_id'].' ">修改</a> | 
             <a href="delflower.php?id='.$row['wn_id'].'" >删除</a>
        </td>';
   echo '</tr>';  
  }
  echo '</table>';  
  $totalrows = count($result);
  echo "<table align='center'><tr><td>共有{$totalrows}种鲜花</td></tr></table>";  
 ?> 
 <!-- <center><h3><a href="search.php?id='.$row['wn_id'].'" >搜索</a></h3></center>  -->
 </body>
</html>
